﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

#endregion

using Weazel.Badger.Vhdl.Types;

namespace Weazel.Badger.Vhdl.Operators.Binary
{
  public class LessThan : BinaryFunction
  {
    private static BinaryTypeMap[] typeMaps = new BinaryTypeMap[]
      {
        new BinaryTypeMap(Types.Types.Boolean, Types.Types.Boolean, Types.Types.Boolean, true),
        new BinaryTypeMap(Types.Types.Character, Types.Types.Character, Types.Types.Boolean, true),        

        new BinaryTypeMap(Types.Types.Unsigned, Types.Types.Unsigned, Types.Types.Boolean, true),
        new BinaryTypeMap(Types.Types.Unsigned, Types.Types.Signed, Types.Types.Boolean, true),
        new BinaryTypeMap(Types.Types.Signed, Types.Types.Signed, Types.Types.Boolean, true),
        
        new BinaryTypeMap(Types.Types.Unsigned, Types.Types.Integer, Types.Types.Boolean, true),
        new BinaryTypeMap(Types.Types.Integer, Types.Types.Unsigned, Types.Types.Boolean, true),
        new BinaryTypeMap(Types.Types.Signed, Types.Types.Unsigned, Types.Types.Boolean, true),
        new BinaryTypeMap(Types.Types.Signed, Types.Types.Integer, Types.Types.Boolean, true),
        new BinaryTypeMap(Types.Types.Integer, Types.Types.Signed, Types.Types.Boolean, true),
        new BinaryTypeMap(Types.Types.StdLogic, Types.Types.StdLogic, Types.Types.Boolean, true)
      };

    private static BinaryTypeMap[] signedTypeMaps = new BinaryTypeMap[]
      {
        new BinaryTypeMap(Types.Types.Boolean, Types.Types.Boolean, Types.Types.Boolean),
        new BinaryTypeMap(Types.Types.Character, Types.Types.Character, Types.Types.Boolean), 
        new BinaryTypeMap(Types.Types.Signed, Types.Types.Signed, Types.Types.Boolean),

        /*
        new BinaryTypeMap(Types.Unsigned, Types.Unsigned, Types.Boolean),
        
        new BinaryTypeMap(Types.Unsigned, Types.Signed, Types.Boolean),
        new BinaryTypeMap(Types.Signed, Types.Unsigned, Types.Boolean),
        new BinaryTypeMap(Types.Signed, Types.Integer, Types.Boolean),
        new BinaryTypeMap(Types.Integer, Types.Signed, Types.Boolean),
        new BinaryTypeMap(Types.StdLogic, Types.StdLogic, Types.Boolean)
      */
      };

    public override BinaryTypeMap[] SignedTypeMaps
    {
      get
      {
        return signedTypeMaps ;
      }
    }

    public override BinaryTypeMap[] UnsignedTypeMaps
    {
      get
      {
        return typeMaps;
      }
    }

    public LessThan()
    {
    }

    public override string ToString(string left, string right, int width)
    {
      return string.Format("{0} < {1}", left, right);
    }
  }
}
